package com.zzl.bonds.ticket.controller;

import com.zzl.apidoc.annotation.ApidocController;
import com.zzl.apidoc.annotation.ApidocOperation;
import com.zzl.apidoc.annotation.ApidocParam;
import com.zzl.bonds.ticket.dto.bookrelation.TicketBookRelationBatchAddDto;
import com.zzl.bonds.ticket.service.TicketBookRelationService;
import com.zzl.general.common.apidoc.annotation.ApidocReturnR;
import com.zzl.general.common.ctrl.WebBaseCtrl;
import com.zzl.general.common.exception.SysException;
import com.zzl.general.common.utils.LogUtils;
import com.zzl.general.common.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 联系人票关系表
 *
 * @author gull
 * @date 2021-12-07 16:29:41
 */
@ApidocController("5联系人票关系表")
@RestController
@RequestMapping("bondsticket/tickebookrelation")
@Slf4j
public class TicketBookRelationController extends WebBaseCtrl {
    @SuppressWarnings("all")
    @Autowired
    private TicketBookRelationService ticketBookRelationService;


    @PostMapping("/saveBatchTicketBook")
    @ApidocOperation(description = "1开立/转让/融资/异常申请，发送消息", operationId = "ticket/tickebookrelation/saveOpenBatch")
    @ApidocReturnR
    public Result saveBatchTicketBook(@ApidocParam(name = "开立/转让/融资/异常申请，发送消息实体", required = true) @RequestBody @Validated
                                              TicketBookRelationBatchAddDto ticketBookRelation) {
        try {
            ticketBookRelationService.saveTicketBookRelationBatch(ticketBookRelation, this.getUser());
            return Result.ok();
        } catch (SysException e) {
            LogUtils.logSysException(log, e);
            return Result.error(e.getMsg());
        }
    }

}
